package helper

import (
	"fmt"

	"github.com/dop251/goja"
)

// go语言实现js console.log
type console struct{}

func newConsole(vm *goja.Runtime) *goja.Object {
	c := &console{}
	obj := vm.NewObject()
	err := obj.Set("log", c.log)
	if err != nil {
		return nil
	}
	return obj
}

func (c *console) log(msg string) {
	fmt.Println("js.log-->", msg)
}
